package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IStrategyCommentService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping("/strategyComment")
public class StrategyCommentController {
    @Autowired
    private IStrategyCommentService commentService;

    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") QueryObject qo, Model model){
        qo.setOrderby("sc.createTime desc");
        PageInfo<Strategy> pageInfo = commentService.queryForList(qo);
        model.addAttribute("pageInfo",pageInfo);
        return "strategyComment/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyComment comment){
        commentService.saveOrUpdate(comment,null);
        return new JSONResult();
    }
}
